package com.example.myapplication.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import com.example.myapplication.R;
import com.example.myapplication.bean.MoneyData;
import com.example.myapplication.util.RandomUtil;

public class HappyActivity extends AppCompatActivity {

    TextView moneyText;
    TextView timeText;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_happ_mi10);

        moneyText = findViewById(R.id.happy_money_text);
        moneyText.setOnClickListener(moneyClickListener);
        timeText = findViewById(R.id.happy_time_text);

        MoneyData moneyData = (MoneyData)getIntent().getSerializableExtra("moneyData");
        moneyText.setText("-"+moneyData.getMoney());
        timeText.setText(moneyData.getStartTime());

        TextView codeText = findViewById(R.id.happy_code_text);
        codeText.setText(RandomUtil.getRandom10TO99().toString());
    }

    /**
     * 金钱跳转到主页面
     */
    View.OnClickListener moneyClickListener = new View.OnClickListener(){
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(HappyActivity.this,MainActivity.class);
            startActivity(intent);
        }
    };

}
